/**
 * 
 */
package com.gopay.scheduler.dao.sms.impl;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.domain.log.LogSMSSend;
import com.gopay.common.util.DateUtils;
import com.gopay.scheduler.dao.sms.LogSMSSendDAO;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.util.Date;

/**
 * 短信日志DAO
 * @LogSMSSendDAO.java
 * @author pansc
 * @2017-12-18
 */
@Repository("logSMSSendDAO")
public class LogSMSSendDAOImpl extends BaseDAOImpl<LogSMSSend, Integer> implements LogSMSSendDAO {

    /*
     * (non-Javadoc)
     * 
     * @see
     * com.gopay.portal.dao.sms.LogSMSSendDAO#findToDayCountByMobileNum(java
     * .lang.String)
     */
    @Override
    public int findToDayCountByMobileNum(String mobNum, String mobileID,String remarks) {
        DetachedCriteria criteria = DetachedCriteria.forClass(LogSMSSend.class);
        criteria.add(Restrictions.eq("mobileNum", mobNum));
        criteria.add(Restrictions.eq("mobileID", mobileID));
        criteria.add(Restrictions.eq("remarks",remarks));
        String strDate = DateUtils.format(new Date(), "yyyyMMdd");
        criteria.add(Restrictions.between("sendTime", DateUtils.strToDate(strDate + "000000"),
                DateUtils.strToDate(strDate + "235959")));
        return this.findCountByCriteria(criteria);
    }

}
